package ${packageName}.controller.${moduleName};

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import ${packageName}.service.${moduleName}.${classInfo.className}Service;

import com.dbapp.dsc.model.common.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

import com.dbapp.dsc.model.common.ResultModel;
import com.dbapp.dsc.model.vo.BoolResultVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.dbapp.dsc.common.ResponseVO;
import com.dbapp.dsc.model.dto.${moduleName}.${classInfo.className}DTO;
import com.dbapp.dsc.model.dto.${moduleName}.${classInfo.className}QueryDTO;
import ${packageName}.model.entity.${moduleName}.${classInfo.className};

import java.util.List;


/**
 * Controller to ${classInfo.className}.
 *
 * @author ${authorName} ${.now?string('yyyy-MM-dd')}
 */
@RequestMapping("/${classInfo.className?uncap_first}")
@RestController
public class ${classInfo.className}Controller {

    @Autowired
    private ${classInfo.className}Service ${classInfo.className?uncap_first}Service;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @Operation(method = "add")
    public ResultModel<BoolResultVO> add(@RequestBody @Valid ${classInfo.className}DTO dto) {
        BoolResultVO vo = new BoolResultVO();
        ${classInfo.className?uncap_first}Service.add(dto);
        vo.setStatusResult(true);
        return ResultModel.success(vo);
    }

    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    @Operation(method = "delete")
    public ResultModel<BoolResultVO> delete(@RequestParam Long id) {
        BoolResultVO vo = new BoolResultVO();
        vo.setStatusResult(true);
        ${classInfo.className?uncap_first}Service.delete(id);
        return ResultModel.success(vo);
    }

    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @Operation(method = "list")
    public ResultModel<ResponseVO> tagList(@RequestBody @Valid ${classInfo.className}QueryDTO dto) {
        ResponseVO<${classInfo.className}DTO> responseVO = new ResponseVO<>();
        responseVO.setDataList(${classInfo.className?uncap_first}Service.list(dto));
        return ResultModel.success(responseVO);

    }

    @RequestMapping(value = "/page", method = RequestMethod.POST)
    @Operation(method = "page")
    public ResultModel<PageResult<${classInfo.className}DTO>> page(@RequestBody @Valid  ${classInfo.className}DTO dto) {
        PageResult<${classInfo.className}DTO> page = ${classInfo.className?uncap_first}Service.page(dto);
        return ResultModel.success(page);
    }
}